package com.book.util;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MySpringListener implements ServletContextListener {

	@Override
	public void contextInitialized(ServletContextEvent event) {
		ServletContext application = event.getServletContext();
		String contextConfigLocation = application.getInitParameter("contextConfigLocation");
		ApplicationContext ctx = new ClassPathXmlApplicationContext(contextConfigLocation);
		//page request session application
		application.setAttribute("ctx", ctx);
	}

	@Override
	public void contextDestroyed(ServletContextEvent event) {

	}

}
